/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.agenda.model.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Ronildo
 */
@Entity
@Table(name = "AM_TB_REGI")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AmTbRegi.findAll", query = "SELECT a FROM AmTbRegi a"),
    @NamedQuery(name = "AmTbRegi.findByCdRegi", query = "SELECT a FROM AmTbRegi a WHERE a.cdRegi = :cdRegi"),
    @NamedQuery(name = "AmTbRegi.findByNmRegi", query = "SELECT a FROM AmTbRegi a WHERE a.nmRegi = :nmRegi")})
public class AmTbRegi implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id
    @Basic(optional = false)
    @Column(name = "CD_REGI")
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "seq_AM_TB_REGI")
    @SequenceGenerator(name="seq_AM_TB_REGI", sequenceName = "seq_AM_TB_REGI")
    private Short cdRegi;
    
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "NM_REGI")
    private String nmRegi;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cdRegi")
    private Collection<AmTbBair> amTbBairCollection;

    public AmTbRegi() {
    }

    public AmTbRegi(Short cdRegi) {
        this.cdRegi = cdRegi;
    }

    public AmTbRegi(Short cdRegi, String nmRegi) {
        this.cdRegi = cdRegi;
        this.nmRegi = nmRegi;
    }

    public Short getCdRegi() {
        return cdRegi;
    }

    public void setCdRegi(Short cdRegi) {
        this.cdRegi = cdRegi;
    }

    public String getNmRegi() {
        return nmRegi;
    }

    public void setNmRegi(String nmRegi) {
        this.nmRegi = nmRegi;
    }

    @XmlTransient
    public Collection<AmTbBair> getAmTbBairCollection() {
        return amTbBairCollection;
    }

    public void setAmTbBairCollection(Collection<AmTbBair> amTbBairCollection) {
        this.amTbBairCollection = amTbBairCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cdRegi != null ? cdRegi.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AmTbRegi)) {
            return false;
        }
        AmTbRegi other = (AmTbRegi) object;
        if ((this.cdRegi == null && other.cdRegi != null) || (this.cdRegi != null && !this.cdRegi.equals(other.cdRegi))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.agenda.model.entity.AmTbRegi[ cdRegi=" + cdRegi + " ]";
    }
    
}
